<%@ page import="com.aiwei.tdjk.enums.CheckStateEnum" %>
<%@ page import="com.aiwei.tdjk.enums.RechargeTypeEnum" %>
<%@ page import="com.aiwei.tdjk.entity.Delivery" %>
<%@ page import="com.aiwei.tdjk.enums.DeliveryStatusEnum" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/template/common/taglibs.jspf" %>
<es:contentHeader/>


<t:base type="jquery,jquery-ui-bootstrap:bootstrap,jquery-ui-bootstrap:jquery-ui,query-ui-bootstrap:jquery.layout,jquery-ui-bootstrap:font-awesome"></t:base>
<t:base type="jquery-ui-bootstrap:jquery.blockUI,jquery-ui-bootstrap:bootstrap.file-input,bootstrap-datetimepicker,jQuery-Validation-Engine,nicescroll,application"></t:base>


<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/box.css"/>



<div class="box border purple" style="">
    <div class="box-title">
        <h4><i class="fa fa-bars"></i>发货单列表（外销）</h4>
        <div class="tools">
            <a href="#box-config" data-toggle="modal" class="config">
                <i class="fa fa-cog"></i>
            </a>
            <a href="javascript:;" class="reload">
                <i class="fa fa-refresh"></i>
            </a>
            <a href="javascript:;" class="collapse">
                <i class="fa fa-chevron-up"></i>
            </a>
            <a href="javascript:;" class="remove">
                <i class="fa fa-times"></i>
            </a>
        </div>
    </div>

    <div class="box-body" style="display: block;">

        <div data-table="table" class="panel">

            <es:showMessage/>


            <div class="row-fluid tool ui-toolbar">
                <div class="span3">
                    <div class="btn-group">

                        <%--<shiro:hasPermission name="delivery:list:update">--%>
                            <%--<a id="update" class="btn btn-update">--%>
                                <%--<span class="icon-edit"></span>--%>
                                <%--商检（查看）--%>
                            <%--</a>--%>


                            <%--<div class="btn-group last">--%>
                                <%--<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">--%>
                                    <%--<i class="icon-wrench"></i>--%>
                                    <%--更多操作--%>
                                    <%--<span class="caret"></span>--%>
                                <%--</a>--%>
                                <%--<ul class="dropdown-menu">--%>

                                    <%--<li>--%>
                                        <%--<a class="btn btn-link lock-delivery">--%>
                                            <%--<i class="icon-lock"></i>--%>
                                            <%--锁定--%>
                                        <%--</a>--%>
                                    <%--</li>--%>

                                    <%--<li>--%>
                                        <%--<a class="btn btn-link unlocked-delivery">--%>
                                            <%--<i class="icon-unlock"></i>--%>
                                            <%--解锁--%>
                                        <%--</a>--%>
                                    <%--</li>--%>
                                <%--</ul>--%>
                            <%--</div>--%>

                        <%--</shiro:hasPermission>--%>

                        <a id="update" class="btn btn-update">
                            <span class="icon-edit"></span>
                            仓库（确认）
                        </a>

                    </div>
                </div>
                <div class="span9">
                    <%--<%@include file="searchForm.jsp" %>--%>
                </div>
            </div>

            <table id="table" class="sort-table table table-bordered table-hover datatable_single table-striped"
                   data-prefix-url="<%=request.getContextPath()%>/admin/delivery">
                <thead>
                <tr>
                    <%--<th style="width: 20px;">&nbsp;</th>--%>
                    <th style="width: 80px;">
                        <a class="check-all" href="javascript:;">全选</a>
                        |
                        <a class="reverse-all" href="javascript:;">反选</a>
                    </th>
                    <th sort="sn">交货单号</th>
                    <th sort="createDate">创建日期</th>
                    <th sort="memberName">销售订单号</th>
                    <th sort="createDate">装车日期</th>
                    <th>状态</th>

                </tr>
                </thead>
                <tbody>
                <c:forEach items="${page.list}" var="m">
                    <tr>
                        <td class="check">
                            <input type="checkbox" name="ids" value="${m.id}" />
                        </td>
                        <td>${m.deliveryCode}</td>
                        <td><fmt:formatDate value="${m.createDate}" pattern='yyyy年MM月dd日 hh:mm:ss'/></td>

                        <td>${m.saleOrderCode}</td>
                        <td><fmt:formatDate value="${m.carryDate}" pattern='yyyy年MM月dd日'/></td>
                        <td>
                            <c:set var="status" scope="request" value="${m.status }"/>
                            <%=DeliveryStatusEnum.getValue(Integer.parseInt(request.getAttribute("status").toString())).getInfo()%>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <es:page page="${page}"/>
        </div>

    </div>
</div>


<es:contentFooter/>
<%@include file="/WEB-INF/template/common/admin/import-sys-js.jspf" %>
<script type="text/javascript">
    $(function () {


        $(".rentShip").click(function() {
            var checkbox = $.table.getAllSelectedCheckbox($(".table"));
            if(!checkbox.length) return;
            var id = checkbox.val();
            var url = ctx + "/admin/bookingContainer/create?" + checkbox.serialize();
            window.location.href =url;
        });



        $(".lock-delivery,.unlocked-delivery").click(function() {

            var checkbox = $.table.getAllSelectedCheckbox($(".table"));
            if(!checkbox.length) return;
            var id = checkbox.val();
            var status = $(this).is(".unlocked-delivery") ? "unlock" : "lock";
            var url = ctx + "/admin/delivery/changeStatus/" + status + "?" + checkbox.serialize();

            var title = status == 'lock' ? "封禁" : "解封";
            var tip = status == 'lock' ? "确认封禁？" : "确认解封？";

            $.app.confirm({
                title: title,
                message : tip,
                ok : function() {
                    window.location.href = url;
                }
            });
        });
    });
</script>

